﻿using System.Diagnostics;

namespace GameofTestforReaction
{
    internal class Program
    {
        enum characters
        {
            q, w, e, r, t, y, u, i, o, p, a, s, d, f, g, h, j, k, l, z, x, c, v, b, n, m
        }
        static void Main(string[] args)
        {

            Console.WriteLine("游戏规则：请输入与屏幕一样的字母");
            Console.Write("请输入游戏次数");
            //输入游戏次数
            string num = Console.ReadLine();
            int N = int.Parse(num);
            //开始计时
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            int count = 0;
            //用值访问枚举的函数
            string GetEnumNameByKey(int key)
            {
                return characters.GetName(typeof(characters), key);
            }
            //游戏开始
            for (int i = 0; i < N; i++)
            {
                //随机取1—26的数，并输出对应的字母
                Random random = new Random();
                int randomnum = (int)(random.Next(1, 26));
                Console.WriteLine(GetEnumNameByKey(randomnum));
                string k;
                do
                {
                    k = Console.ReadLine();
                    //如果错，则计数+1
                    if (k != GetEnumNameByKey(randomnum))
                        count++;

                } while (k != GetEnumNameByKey(randomnum));//如果对，则进行下一循环
                //清屏
                Console.Clear();
            }
            Console.Write($"错误次数：{count}");
            Console.WriteLine();
            stopwatch.Stop();
            //运行时间结束
            TimeSpan runtime = stopwatch.Elapsed;
            //输出运行时间                           
            Console.Write($"runtime:{runtime.TotalSeconds}秒");      
        }
    }
}